require(['./config'], () => {
    require(['server', 'swiper', 'nav', 'foot'], (server, Swiper) => {
        class Index {
            constructor() {
                this.init()
            }
            init() {
                let mySwiper = new Swiper('.swiper-container', {
                    scrollbar: {
                        el: '.swiper-scrollbar',
                    },
                    autoplay: true
                });

                $.get(server.baseServerUrl + '/api/goods/list', resp => {

                    // bracelets, necklaces, earrings, rings
                    let necklaces = resp.body.list.filter((item) => item.jewelryType == "necklaces");
                    let bracelets = resp.body.list.filter((item) => item.jewelryType == "bracelets");
                    let earrings = resp.body.list.filter((item) => item.jewelryType == "earrings");
                    let rings = resp.body.list.filter((item) => item.jewelryType == "rings");

                    $('.father-class li:eq(0) img').attr('src', necklaces[0].img.split('@')[0]);
                    $('.father-class li:eq(1) img').attr('src', bracelets[0].img.split('@')[0]);
                    $('.father-class li:eq(2)  img').attr('src', earrings[0].img.split('@')[0]);
                    $('.father-class li:eq(3)     img').attr('src', rings[0].img.split('@')[0]);
                    $('.main .father-class').on('click', 'a', function() {
                        open('/html/category.html?' + $(this).parents('.father-class').attr('type-title') + '=' + $(this).attr('je-type'));
                    })

                })


            }
        }
        new Index()
    })
})